<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Axios测试</title>
		<script src="../js/axios.js"></script>
	</head>
	<body>
		<h1>Axios测试案例-2</h1>
		<script>
			
			/* 
				语法:
					1.参数 axios.post(URL地址,数据对象)
					2.注意事项: 与axios.get(url,{params:对象})请求写法不一样.
			 */
			let url1 = "http://localhost:8080/axios/saveUser"
			let user1 = {id:100, name:"猫", age:2, sex: "母"}
			axios.post(url1,user1)
				 .then(function(promise){
					 console.log(promise.data)
				 })
			
			/**
			 * 业务需求:
			 * 		完成用户的修改操作. 
			 * 		将ID=100的数据 name改为张三 age改为18 sex改为女
			 * URL: http://localhost:8080/axios/updateUser
			 * 返回值:  修改成功!!!   数据要求后端打印
			 */
			let url2="http://localhost:8080/axios/updateUser"
			let user2={id:100,name:"张三",age:18,sex:"女"}
			axios.put(url2,user2)
				 .then(function(promise){
					 console.log(promise.data)
				 })
			
			/**
			 * 业务需求:根据ID删除数据 
			 * URL1: http://localhost:8080/axios/deleteUserById?id=1
			 * URL2: http://localhost:8080/axios/deleteUserById/1
			 * URL3: http://localhost:8080/axios/deleteUserById
			 * 返回值:  删除成功!!!!!   数据要求后端打印
			 */
			//let user3 = {id:1}
			//axios.delete(url,{params: user3}).then()
		</script>
	</body>
</html>





